package com.atguigu.dga.governance.assessor.spec;

import com.atguigu.dga.governance.assessor.Assessor;
import com.atguigu.dga.governance.bean.AssessParam;
import com.atguigu.dga.governance.bean.GovernanceAssessDetail;
import com.atguigu.dga.governance.bean.GovernanceMetric;
import com.atguigu.dga.meta.bean.TableMetaInfo;
import com.atguigu.dga.meta.constants.MetaConst;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.Date;

@Component("HAS_TEC_OWNER")
public class HasTecOwnerAssessor extends Assessor {


    @Override
    public void checkProblem(AssessParam assessParam, GovernanceAssessDetail governanceAssessDetail) {
        TableMetaInfo tableMetaInfo = assessParam.getTableMetaInfo();
        String governanceUrl = assessParam.getGovernanceMetric().getGovernanceUrl();
        if (tableMetaInfo.getTableMetaInfoExtra().getTecOwnerUserName()==null
                ||tableMetaInfo.getTableMetaInfoExtra().getTecOwnerUserName().trim().length()==0
                ||tableMetaInfo.getTableMetaInfoExtra().getTecOwnerUserName().equals(MetaConst.OWNER_UNSET)){
            //设置考评结果
            governanceAssessDetail.setAssessScore(BigDecimal.ZERO);
            governanceAssessDetail.setAssessProblem("技术负责人未填写");
            governanceAssessDetail.setGovernanceUrl(governanceUrl.replace("{tableId}",tableMetaInfo.getId().toString()));
        }
    }
}
